﻿using System;
using System.Windows.Forms;
using System.Collections.Generic;
using Client.TopLevel;

namespace PersApp
{
    public partial class AppForm : Form
    {
        private IManagerEmployee mEmployee = null;

        public AppForm(IManagerEmployee employee)
        {
            InitializeComponent();

            WindowState = FormWindowState.Maximized;

            mEmployee = employee;

            byte role = mEmployee.GetEmployee().Role;

            if (role == TLEmployee.ROLE_EMPLOYEE)
                HideManagersFunctionality();

        }

        private void dataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserDataForm userForm = new UserDataForm(mEmployee.GetEmployee(),
                mEmployee.GetReport(DateTime.MinValue, DateTime.Now),
                mEmployee.GetPosition(), mEmployee);
            userForm.MdiParent = this;
            userForm.Show();

            /* string login, name, position = string.Empty;
            int salary = 0;

            Employee employee = RepMan.EmployeeRepository.GetData();
            login = employee.Login;
            name = employee.Name;

            IEnumerable<Position> positions = RepMan.PositionRepository.GetAll();
            foreach (Position p in positions)
                if (p.Id != employee.PositionId)
                {
                    position = p.Name;
                    salary = p.Salary;
                }

            UserDataForm userForm = new UserDataForm(RepMan, user, employee, position, salary);
            userForm.MdiParent = this;
            userForm.Text = "Мои данные:";
            userForm.Show(); */
        }

        private void employeesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EmployeesForm employeesForm = new EmployeesForm(mEmployee);
            employeesForm.MdiParent = this;
            employeesForm.Show();
        }

        private void HideManagersFunctionality()
        {
            manageToolStripMenuItem.Visible = false;
        }

        private void задачиToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            TaskForm taskForm = new TaskForm(mEmployee, false);
            taskForm.MdiParent = this;
            taskForm.Show();
        }

        private void задачиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TaskForm taskForm = new TaskForm(mEmployee, true);
            taskForm.MdiParent = this;
            taskForm.Show();
        }

        private void графикЗарплатToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SalaryForm salaryForm = new SalaryForm(mEmployee);
            salaryForm.MdiParent = this;
            salaryForm.Show();
        }

        private void начислениеЗарплатыToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PaymentForm payForm = new PaymentForm(mEmployee);
            payForm.MdiParent = this;
            payForm.Show();
        }

        private void отчетыToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ReportForm payForm = new ReportForm(mEmployee);
            payForm.MdiParent = this;
            payForm.Show();
        }
    }
}
